package com.bosssoft.boss_exam_db.validator.common;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.Date;

/***
 * @Author lys(cherish)
 * @Phone 17720799636
 * @Date  2019/3/13
 * @Descriptionh 用户名校验
 **/
public class BirthdayValidator implements ConstraintValidator<Birthday, Date> {

    @Override
    public void initialize(Birthday birthday) {
    }

    @Override
    public boolean isValid(Date birthday, ConstraintValidatorContext constraintValidatorContext) {
//        如果出生日期比当前日期晚，则为非法生日
        long currentTime = System.currentTimeMillis();
        long birthdayTime = birthday.getTime();
        if(currentTime<birthdayTime){
            return false;
        }
        return true;
    }
}
